package com.product.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.product.app.mapper.CategoryMapper;
import com.product.app.service.CategoryService;
import com.tamll.bean.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public Page<Category> getList(Integer pageNumber, Integer num) {
        Page<Category> productPage=new Page<>(1,16);
        QueryWrapper<Category> queryWrapper=new QueryWrapper<>();
        Page<Category> categoryPage = categoryMapper.selectPage(productPage, queryWrapper);
        System.out.println("总页数:"+categoryPage.getPages());
        System.out.println("总记录数:"+categoryPage.getTotal());
        return categoryPage;

    }

    @Override
    public Category get(Integer product_category_id) {
        QueryWrapper<Category> wrapper=new QueryWrapper<>();
        wrapper.eq("categoryId",product_category_id);
        Category category = categoryMapper.selectOne(wrapper);
        return category;
    }

}
